package controller;

import gui.TokenGetter;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import client.TokenClient;

public class TimerAction implements ActionListener {

	private TokenClient client;
	private TokenGetter gui;
	private int counter = 0;

	public TimerAction(TokenGetter gui, TokenClient client) {
		this.gui = gui;
		this.client = client;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		try {
			if (counter++ - 60 == 0) {
				gui.getTxt_token().setText(client.getToken() + "");
				counter = 0;
				gui.getPb_countDown().setValue(60);
			}else if(counter % 5 == 0){
				gui.getPb_countDown().setValue(gui.getPb_countDown().getValue()-5);
			}
		} catch (Exception e2) {
			e2.printStackTrace();
		}
	}

}
